﻿#ifndef BASEFRAME_H
#define BASEFRAME_H
#include "IGBTProtocol_global.h"
#include <QByteArray>

namespace IGBTProtocol
{
    class IGBTPROTOCOL_EXPORT BaseFrame
    {
        protected:
            BaseFrame();
        public:
            BaseFrame(FrameHeaderType frameHeader, unsigned int dataSize);
            ~BaseFrame();

        protected:
            FrameHeaderType _frameHeader;
            unsigned int _dataSize;
            unsigned char _crc;

        public:
            FrameHeaderType frameHeader() const { return _frameHeader; }

            static unsigned char calcCRC(QByteArray* buff, unsigned int size);
            static FrameHeaderType judge(QByteArray* buff);
            virtual bool depack(QByteArray* buff);
            virtual unsigned int frame(QByteArray* buff, bool tail = false);
    };
}


#endif // BASEFRAME_H
